<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="utf-8">
</head>
<body>
<h1>学生信息修改</h1>
<?php
include_once("database.php");
if (isset($_POST["submit"])&&$_POST["submit"]=="修改") {
	$studentno=$_POST['studentno'];
	$studentname=$_POST['studentname'];
	$xingbie=$_POST['xingbie'];
	$number=$_POST['number'];
	$class=$_POST['class'];
	$mobile=$_POST['mobile'];
	$credit=$_POST['credit'];
	$studentinfos=$_POST['studentinfos'];
	//构建修改语句
	$updatebookssql="update students set studentname='$studentname',xingbie='$xingbie',number='$number',class='$class',mobile='$mobile',credit='$credit',studentinfos='$studentinfos' where studentno='$studentno'";
	@mysql_query($updatebookssql) or die("修改学生信息失败:".mysql_error()."<br/>");
	//然后跳转到查询界面
	echo "修改序号为:$studentno 书籍数据成功!<br/><br/>跳转到学生查询页面......<br/>";
	header("Refresh:3;url=selectstudent.php");
	exit;
}
if(isset($_GET["studentno"])){
	$No=$_GET["studentno"];
	echo "当前需要修改的序号为:{$No}<br/>";
}else{
	echo '<p>请先往"学生查询"界面查询到指定的信息然后再进行更新动作!</p>';
	exit;
}
$No=$_GET["studentno"];
$selectsql="select * from students where studentno='$No'";
$result=mysql_query($selectsql);//查询数据库
$row=mysql_fetch_array($result,MYSQL_ASSOC);
$studentno=$row['studentno'];
$studentname=$row['studentname'];
$xingbie=$row['xingbie'];
$number=$row['number'];
$class=$row['class'];
$mobile=$row['mobile'];
$credit=$row['credit'];
$studentinfos=$row['studentinfos'];
$updatetable=<<<form
<form action="" method="post">
<h2>添加学生</h2>
N&nbsp;&nbsp;o:&nbsp;<input type="text" name="studentno" value="$studentno" required="required">&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
姓名:&nbsp;<input type="text" name="studentname" value="$studentname"><br/><br/>
学号:&nbsp;<input type="text" name="number" value="$number">
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
性别:&nbsp;<input type="radio" name="xingbie" value="男" checked="checked">男&nbsp;&nbsp; 
<input type="radio" name="xingbie" value="女">女
<br/><br/>
班级:&nbsp;<input type="text" name="class" value="$class">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
手机号:&nbsp;<input type="text" name="mobile" value="$mobile"><br/><br/>
信用:&nbsp;<input type="radio" name="credit" value="差" checked="checked">差 
&nbsp;<input type="radio" name="credit" value="合格">合格
&nbsp;<input type="radio" name="credit" value="良好">良好
&nbsp;<input type="radio" name="credit" value="优秀">优秀
<br/><br/>
备注信息: <br/> <textarea name="studentinfos" rows="10" cols="140">{$studentinfos}</textarea><br/><br/>
<input type="submit" name="submit" value="修改">
</form>
form;
echo $updatetable;

?>
</body>
</html>